from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource,AnyLaunchDescriptionSource
from launch.substitutions import PathJoinSubstitution
from launch_ros.substitutions import FindPackageShare
from launch_ros.actions import PushRosNamespace
import launch_ros.actions


def generate_launch_description():

    # Include the origincar_bringup.launch.py file
    origincar_bringup_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([
            PathJoinSubstitution([
                FindPackageShare('origincar_base'),
                'launch',
                'origincar_bringup.launch.py'
            ])
        ])
    )


    usb_websocket_display_launch = IncludeLaunchDescription(
        AnyLaunchDescriptionSource([
            PathJoinSubstitution([
                FindPackageShare('origincar_bringup'),
                'launch',
                'usb_websocket_display.launch.py'
            ])
        ])
    )


    # Include the cv_detection.launch.py file
    fcos_detection = launch_ros.actions.Node(
            package="fcos_detection",
            executable="fcos_detection" 
    )

    qrcode_cpp = launch_ros.actions.Node(
            package="qrcode_cpp",
            executable="qrcode_cpp" 
    )


    ld = LaunchDescription()
    ld.add_action(origincar_bringup_launch)
    #ld.add_action(usb_websocket_display_launch)
    ld.add_action(qrcode_cpp)
    ld.add_action(fcos_detection)

    return ld